#!/bin/bash

echo "<registryObjects xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"
                 xmlns=\"http://ands.org.au/standards/rif-cs/registryObjects http://www.openarchives.org/OAI/2.0/\"
                 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
                 xsi:schemaLocation=\"http://ands.org.au/standards/rif-cs/registryObjects http://services.ands.org.au/documentation/rifcs/schema/registryObjects.xsd\">" > ForAAD_Examples/AAD_RegistryObjects.xml

ls "/home/anucsiro/projects/AAD/ForTransform" | while read f; do
    fileNamePath="/home/anucsiro/projects/AAD/ForTransform/""$f"
    fileNameNoExtension=${f%.*}
    echo File: $fileNamePath
    echo Transforming $fileNamePath
    echo java -jar /home/anucsiro/workspace/XML/XSLT/saxon9he.jar "/home/anucsiro/projects/AAD/ForTransform/""$f" /home/anucsiro/workspace/XML/XSLT/ISO19139_To_RIFCS/GA/GA_rif_refactored.xsl
    java -jar /home/anucsiro/workspace/XML/XSLT/saxon9he.jar \
        "/home/anucsiro/projects/AAD/ForTransform/""$f" \
        /home/anucsiro/workspace/XML/XSLT/ISO19139_To_RIFCS/AAD/AAD_rif_in_progress.xsl \
        > /home/anucsiro/workspace/XML/ShellScripts/ForAAD_Examples/$fileNameNoExtension"_rif-cs.xml" 
    echo XML written to /home/anucsiro/workspace/XML/ShellScripts/ForAAD_Examples/$fileNameNoExtension"_rif-cs.xml"

    cat ForAAD_Examples/${fileNameNoExtension}_rif-cs.xml >> ForAAD_Examples/AAD_RegistryObjects.xml

done












